import { MessageEventMap } from "./types"
import receiver from './EventHandler'
self.addEventListener('message', <K extends keyof MessageEventMap = keyof MessageEventMap>(e: MessageEvent<MessageEventMap>) => {
  const { data } = e
  for (const key in receiver) {
    if (Object.prototype.hasOwnProperty.call(data, key)) {
      receiver[key as K]?.(data[key as K])
      break
    }

  }
})